var e = getApp();

Component({
    properties: {
        prop_goods_info: {
            type: null
        },
        goodsId: {
            type: Number
        },
        goodsType: {
            type: String
        },
        hoet: {
            type: null
        }
    },
    data: {
        goodsInfo: {},
        rechargeType: {},
        rechargeItem: {},
        rechargeSpecId: 0,
        displayOptions: [],
        optionsId: 0,
        show1: !1,
        service_QRcode: "",
        service_mobile: "",
        cservice: "",
        likeArr: [],
        swipeIndex: 0,
        mobile: "",
        bannerUrl: "",
        posterShow: !1,
        mobileCity: ""
    },
    ready: function() {
        var e = this.properties.prop_goods_info, t = {}, o = this.data.goodsInfo = e.get_goods, i = o.has_many_specs[0];
        this._handClickSpecs(i.specitem[0]), t.goodsInfo = o, t.rechargeType = i, e && e.plugin && e.plugin.phoneBillPro && (t.bannerUrl = e.plugin.phoneBillPro.banner), 
        e.customer_service && (t.service_QRcode = e.customer_service.service_QRcode, t.service_mobile = e.customer_service.service_mobile, 
        t.cservice = e.customer_service.cservice);
        var a = o.show_push.slice(0, 30), s = [];
        a.forEach(function(e, t) {
            var o = Math.floor(t / 6);
            s[o] || (s[o] = []), s[o].push(e);
        }), t.likeArr = s, this.setData(t);
    },
    methods: {
        tapInpC: function() {
            var t = this;
            if (11 == this.data.mobile.length) {
                var o = e.getNetAddresss("plugin.phone-bill-pro.frontend.controller.phone-query.get-phone-info");
                e._getNetWork({
                    url: o,
                    data: {
                        mobile: this.data.mobile
                    },
                    success: function(e) {
                        var o = e.data;
                        !1, 1 == o.result && t.setData({
                            mobileCity: "".concat(o.data.city, " ").concat(o.data.isp)
                        });
                    },
                    fail: function() {
                        !1;
                    }
                });
            } else this.setData({
                mobileCity: ""
            });
        },
        handClickSpecs: function(e) {
            var t = e.currentTarget.dataset.item;
            this._handClickSpecs(t);
        },
        _handClickSpecs: function(e) {
            if (this.data.rechargeSpecId != e.id) {
                for (var t = this.data.goodsInfo.has_many_options, o = [], i = 0; i < t.length; i++) t[i].specs.indexOf(e.id) >= 0 && o.push(t[i]);
                this.setData({
                    rechargeSpecId: e.id,
                    rechargeItem: e,
                    displayOptions: o,
                    optionsId: 0
                });
            }
        },
        handClickOptions: function(e) {
            var t = e.currentTarget.dataset.item;
            this.setData({
                optionsId: t.id
            });
        },
        onChangeSwipeIndex: function(e) {
            var t = e.detail.current;
            this.setData({
                swipeIndex: t
            });
        },
        gotoDetailV2: function(e) {
            var t = e.currentTarget.dataset.id;
            wx.navigateTo({
                url: "/packageA/detail_v2/detail_v2?id=" + t
            });
        },
        gotoChat: function(t) {
            var o = t.currentTarget.dataset.cservice + "&goods_id=" + this.data.goodsId;
            wx.navigateTo({
                url: o,
                fail: function(t) {
                    e.tips("客服路由出错");
                }
            });
        },
        setCserviceFlag: function() {
            this.setData({
                show1: !this.data.show1
            });
        },
        gotoOrderList: function() {
            wx.navigateTo({
                url: "/packageA/member/myOrder_v2/myOrder_v2"
            });
        },
        gotoIndex: function() {
            wx.reLaunch({
                url: "/packageG/index/index"
            });
        },
        setPosterShow: function() {
            this.setData({
                posterShow: !0
            });
        },
        setTopping: function() {
            wx.pageScrollTo({
                scrollTop: 0
            });
        },
        sendRecharge: function() {
            var t = this.data, o = t.mobile, i = t.goodsId, a = t.optionsId;
            if (!o) return e.tips("请输入充值手机号码！"), !1;
            return /^[1][0-9]{10}$/.test(o) ? a <= 0 ? e.tips("请选择规格ID") : void wx.navigateTo({
                url: "/packageD/buy/myOrder_v2/myOrder_v2?tag=-2&total=1&&goodsId=" + i + "&optionsId=" + a + "&mobile=" + o
            }) : (e.tips("请输入正确的充值手机号码！"), !1);
        }
    }
});